﻿#coding=utf-8 
#from heroes import *
#from Unit import *
from Active import *
from Ability import *
from Unit import *
from Ui import *
import random

class GameText:
    texts = []
    dimension = 0
    index = 0
    
    def __init__(self, dimension, texts = []):
        self.dimension = dimension
        self.texts = texts
        
    def add(self, text):
        if len(text) != self.dimension:
            return False
        self.texts.append(text)
        return True
    
    def set_index(self, index):
        if len(self.texts) == 0:
            return False
        if index < 0 or index >= len(self.texts):
            return False
        self.index = index
        return True
    
    def set_random_index(self):
        if len(self.texts) == 0:
            return False
        self.index = random.randint(0, len(self.texts) - 1)
        return True
    
    def get_text(self, dimension_index):
        if len(self.texts) == 0:
            return ""
        if dimension_index < 0 or dimension_index >= self.dimension:
            return ""
        return self.texts[self.index][dimension_index]
        

class Game:
    """description of class"""

    ui = None
    
    time_delay = 0
    

    def __init__(self, ui, time_delay):
        self.ui = ui
        self.time_delay = time_delay

    #def set(self, ui, time_delay, cd_queue):
        

    def run(self):
        pass

if __name__ == "__main__":
    
    g = Game(CmdConsoleUi(), 1)
    
    units = []


    
    abilities = []
    ability = NormalAttact(g, None, "普通攻击", 50, 1, 1, 10, GameText(2, [["%s沉重的一拳", "%s的拳头打在了%s的身上"], ["%s一掌劈了过去", "%s这一掌打了%s一个正着"]]))
    abilities.append(ability)
    
    ability = NormalMagic(g, None, "波动拳", 120, 100, 1, 1, 15, GameText(2, [["%s聚气发出波动", "%s的波动拳打在了%s的身上"]]))
    abilities.append(ability)
    
    unit = UnitBase(g, "ligh", 360, 275, 5, 25, 290, 0, 50, 1, 50, 15, 20, abilities)
    units.append(unit)

    

    
    abilities = []
    
    ability = NormalAttact(g, None, "普通攻击", 78, 2, 2, 2, GameText(2, [["%s轮起左腿", "%s的脚重重的踢在了%s的胸前"], ["%s一个回身，右脚向后踹去", "%s这一脚狠狠地踹中了%s的小腹"], ["%s高抬起一只腿向下劈去", "%s脚跟劈中%s的头部"]]))
    abilities.append(ability)
    
    ability = NormalAttact(g, None, "快速连踢", 58, 1, 2, 8, GameText(2, [["%s突然抬起右腿发动连踢", "%s连续踢了%s一脚"], ["%s一个回身，右脚向后连续踹去", "%s连续踹中%s"]]))
    ability.doing_wait = 3
    
    ability.cost_mp = 200
    abilities.append(ability)
    
    unit = UnitBase(g, "少女", 250, 210, 0, 25, 300, 0, 50, 1, 50, 20, 15, abilities)
    units.append(unit)

    bact = BattleActive(g, units, 1000)
    bact.battle_loop()

